cmake_minimum_required (VERSION 2.8)
set (pname stringmanip)

project (${pname} CXX)

set (LIB_VERSION_MAJOR 0)
set (LIB_VERSION_MINOR 1)
set (LIB_VERSION_PATCH 1)
set (LIB_VERSION "${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH}")

message (STATUS "Buiding library ${pname} version ${LIB_VERSION}")

# Compiler flags
set (cxxflags "-Wall -g -O2")
set ( CMAKE_CXX_FLAGS ${cxxflags})
set ( CMAKE_CXX_FLAGS_DEBUG ${cxxflags})
set ( CMAKE_CXX_FLAGS_RELEASE ${cxxflags})

include_directories("${PROJECT_SOURCE_DIR}")

set (libsrc "string_utilities.cc")

# build library
add_library(${pname} SHARED ${libsrc})
set_target_properties(${pname} PROPERTIES VERSION ${LIB_VERSION} SOVERSION ${LIB_VERSION})

# Build and run tests
add_executable(test_trim test_trim.cc)
target_link_libraries (test_trim ${pname})
add_test (Test_trim test_trim)
set_tests_properties (Test_trim PROPERTIES PASS_REGULAR_EXPRESSION "trim test passed")

add_executable(test_split test_split.cc)
target_link_libraries (test_split ${pname})
add_test (Test_split test_split)
set_tests_properties (Test_split PROPERTIES PASS_REGULAR_EXPRESSION "split test passed")

add_executable(test_numbers test_numbers.cc)
target_link_libraries (test_numbers ${pname})
add_test (Test_numbers test_numbers)
set_tests_properties (Test_numbers PROPERTIES PASS_REGULAR_EXPRESSION "number test passed")

enable_testing()
